//
//  BHSportAndPlaceCollectionViewCell.swift
//  BigHealth
//
//  Created by 蔺百好 on 2021/6/9.
//

import UIKit

class BHSportAndPlaceCollectionViewCell: UICollectionViewCell {
    @IBOutlet weak var iconImgView: UIImageView!
    @IBOutlet weak var stadiumName_label: UILabel!
    
    @IBOutlet weak var area_label: UILabel!
    
    @IBOutlet weak var distance_label: UILabel!
    
    @IBOutlet weak var price_one_label: UILabel!
    
    @IBOutlet weak var price_two_label: UILabel!
    
    @IBOutlet weak var good_name_one_label: UILabel!
    
    @IBOutlet weak var good_name_two_label: UILabel!
    
    @IBOutlet weak var line: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.iconImgView.addLayerCorner(4, 0, .white)

    }

    var model: BHCommonStadiumModel! {
        didSet {
            self.iconImgView.sd_setImage(with: URL.init(string: model.cover), placeholderImage: nil, options: .retryFailed, completed: nil)
            self.stadiumName_label.text = model.name
            self.area_label.text = model.showArea

            self.distance_label.isHidden = !BHLocationManager.shared.authed
            self.distance_label.text = model.showDistance
            
            self.price_one_label.isHidden = true
            self.price_two_label.isHidden = true
            self.good_name_one_label.isHidden = true
            self.good_name_two_label.isHidden = true
            if model.goodsArray.count > 0 {
                self.price_one_label.isHidden = false
                self.good_name_one_label.isHidden = false
                let goodModel = model.goodsArray.first
                self.price_one_label.text = "¥"+goodModel!.price
                self.good_name_one_label.text = goodModel!.name
            }
            
            if model.goodsArray.count > 1 {
                self.price_two_label.isHidden = false
                self.good_name_two_label.isHidden = false
                let goodModel = model.goodsArray[1]
                self.price_two_label.text = "¥"+goodModel.price
                self.good_name_two_label.text = goodModel.name
            }
            
            self.line.isHidden = model.goodsArray.count == 0
            
        }
    }
    
    
    static var sportPlaceHeight: CGFloat {
        get {
            return 154
        }
    }
}
